package de.carcophan.jimdb.ejb.entites;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.UniqueConstraint;

@Entity
@Table(uniqueConstraints =
@UniqueConstraint(columnNames = {"USER_ID", "MOVIE_MOVIEID"}))
public class UserMovies implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    @ManyToOne(optional = false)
    private User user;
    @ManyToOne(optional = false)
    private Movie movie;
    @ManyToOne(optional = false)
    private Status movieStatus;
    @Temporal(TemporalType.DATE)
    private Date lastChanged;

    public Date getLastChanged() {
        return lastChanged;
    }

    public void setLastChanged(Date lastChanged) {
        this.lastChanged = lastChanged;
    }

    public UserMovies(Movie movie) {
        this.movie = movie;
    }

    public UserMovies() {
    }

    public Status getMovieStatus() {
        return movieStatus;
    }

    public void setMovieStatus(Status movieStatus) {
        this.movieStatus = movieStatus;
    }

    public Movie getMovie() {
        return movie;
    }

    public void setMovie(Movie movie) {
        this.movie = movie;
    }

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @Override
    public String toString() {
        return "UserMovies{" + "id=" + id + "user=" + user + "movie=" + movie + "movieStatus=" + movieStatus + '}';
    }
}
